package com.buyantech.smweb.excel;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.web.servlet.view.document.AbstractExcelView;

public class ExcelAView extends AbstractExcelView{
	
	@Override
	protected void buildExcelDocument(Map model, HSSFWorkbook workbook,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
//		Page p = (Page)model.get("page");
//		List<A> alist = p.getResult();
		List<String>headers = (List<String>)model.get("headers");

		HSSFSheet sheet = workbook.createSheet("Sheet");
		
		HSSFRow header = sheet.createRow(0);
		for(int i=0;i<headers.size();i++){
			header.createCell(i).setCellValue(headers.get(i));
		}
		
//		int rowNum = 1;
//		for(A a : alist){
//			HSSFRow row = sheet.createRow(rowNum++);
//			row.createCell(0).setCellValue(a.getS1());
//			row.createCell(1).setCellValue(a.getS2());
//			row.createCell(2).setCellValue(a.getS3());
//			row.createCell(3).setCellValue(a.getS4());
//			row.createCell(4).setCellValue(a.getS5());
//			row.createCell(5).setCellValue(a.getS6());
//			row.createCell(6).setCellValue(a.getS7());
//			row.createCell(7).setCellValue(a.getS8());
//			row.createCell(8).setCellValue(a.getS9());
//			row.createCell(9).setCellValue(a.getS10());
//			row.createCell(10).setCellValue(a.getS11()==null?"":a.getS11().toString());
//			row.createCell(11).setCellValue(a.getS12()==null?"":a.getS12().toString());
//			row.createCell(12).setCellValue(a.getS13()==null?"":a.getS13().toString());
//			row.createCell(13).setCellValue(a.getS14()==null?"":a.getS14().toString());
//			row.createCell(14).setCellValue(a.getS15()==null?"":a.getS15().toString());
//			row.createCell(15).setCellValue(a.getS16()==null?"":a.getS16().toString());
//			row.createCell(16).setCellValue(a.getS17()==null?"":a.getS17().toString());
//			row.createCell(17).setCellValue(a.getS18()==null?"":a.getS18().toString());
//			row.createCell(18).setCellValue(a.getS19()==null?"":a.getS19().toString());
//			row.createCell(19).setCellValue(a.getS20()==null?"":a.getS20().toString());
//		}

	}
}